//
//  SYNewFeatureController.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/1/24.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "SYNewFeatureController.h"
#import "SYNewFeatureCell.h"
#import "YDBaseTabBarController.h"
#import "YDABaseTabBarController.h"

#define newFeatureCellCount 3

@interface SYNewFeatureController ()<SYNewFeatureCellDelegate>

//上一次scrollView的位置
@property (nonatomic , assign) CGFloat preoffsetX;

@end

@implementation SYNewFeatureController

static NSString * const reuseIdentifier = @"SYNewFeatureCell";

-(instancetype)init
{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.width   , [UIScreen mainScreen].bounds.size.height);
    layout.minimumLineSpacing = 0;
    layout.minimumInteritemSpacing = 0;
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    return [super initWithCollectionViewLayout:layout];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.collectionView registerClass:[SYNewFeatureCell class] forCellWithReuseIdentifier:reuseIdentifier];
    self.collectionView.bounces = NO;
    self.collectionView.pagingEnabled = YES;
    self.collectionView.showsHorizontalScrollIndicator = NO;
    self.collectionView.showsVerticalScrollIndicator = NO;
    
    [[SYVersionManger sharedInstance] loadAppVersionInformation];
}
#pragma mark <UICollectionViewDataSource>
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return newFeatureCellCount;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    SYNewFeatureCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
    cell.delegate = self;
    cell.imageString = [NSString stringWithFormat:@"newGuideImage0%zd" , indexPath.item + 1];
    [cell btnHiddenWithItem:indexPath.item count:newFeatureCellCount];
    return cell;
}

-(void)newFeatureCellEnterButtonClick
{    
    if ([[SYVersionManger sharedInstance] isCannormalJumpTab]) {
        YDBaseTabBarController *tabbar = [[YDBaseTabBarController alloc] init];
        [UIApplication sharedApplication].keyWindow.rootViewController = tabbar;
    }else{
        YDABaseTabBarController *tabbar = [[YDABaseTabBarController alloc] init];
        [UIApplication sharedApplication].keyWindow.rootViewController = tabbar;
    }
}



@end
